<?php
namespace app\admin\controller;
use think\facade\Db;

class xgyq  {
    public function index() {
        return '11111';
    }
    public function addWorld() { 
        $params = array(
            'certain'=>$_POST['certain'],
            'certain_inc'=>$_POST['certain_inc'],
            'die'=>$_POST['die'],
            'die_inc'=>$_POST['die_inc'],
            'recure'=>$_POST['recure'],
            'recure_inc'=>$_POST['recure_inc'],
            'uncertain'=>$_POST['uncertain'],
            'uncertain_inc'=>$_POST['uncertain_inc'],
            'date'=>$_POST['date'],
        );
        $isSetCur = Db::table('yhq_world_history_count')->where('date','=',$_POST['date'])->find();
        if(!isset($isSetCur)) {
            $result = Db::table('yhq_world_history_count')->insert($params);
        }
        
        // return $params;
        
    }

    public function addChina() {
        $params = array(            
            'certain'=>$_POST['confirm'],
            'certain_inc'=>$_POST['confirm_add'],
            'die'=>$_POST['dead'],
            'die_inc'=>$_POST['dead_add'],
            'recure'=>$_POST['heal'],
            'recure_inc'=>$_POST['heal_add'],
            'localConfirm'=>$_POST['localConfirm'],
            'localConfirm_inc'=>$_POST['localConfirm_add'],
            'date'=>$_POST['date'],
        );
        if(isset($_POST['inboundNum'])) {
            $params['inbound'] = $_POST['inboundNum'];
        }
        if(isset($_POST['inboundIncr'])) {
            $params['inbound_inc'] = $_POST['inboundIncr'];
        }
        $isSetCur = Db::table('yhq_china_history_count')->where('date','=',$_POST['date'])->find();
        if(!isset($isSetCur)) {
            $result = Db::table('yhq_china_history_count')->insert($params);
        }
    }

    public function getChinaHistoryAll() {
        $limit = 0;
        if(isset($_GET['limit'])) {
            $limit = $_GET['limit'];
        }
        $result = Db::table('yhq_china_history_count')->order('date desc')->limit($limit)->select();
        return $result;
    }

    public function getChinaHistoryByPage() {
        $page = isset($_GET['page'])?$_GET['page']:1;
        $count = Db::table('yhq_china_history_count')->count('id');
        $list = Db::table('yhq_china_history_count')->order('date desc')->page($page,10)->select();
        return array('count'=>$count,'list'=>$list);
    }

    public function getProvinceData() {
        $name = isset($_GET['name'])?$_GET['name']:'北京';
        $list = Db::table('yhq_province_history_list')->where('province','=',$name)->select();
        return array('list'=>$list);
    }

    public function setChinaTodayData() {
        
    }

    
}